/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.zentello.sbot;

import com.zentello.sbot.TestSuiteObserver;
import com.zentello.sbot.TestSuite;
import java.io.File;
import static com.zentello.util.Log.*;

/**
 *
 * @author anthony
 */
public class Eval implements Runnable{

    public static void main(String[] args){
        if(args.length >=1){
            File file = new File(args[0]);
            if(file.exists()){
                Eval e = new Eval(null, args);
                e.run();
                return;
            }
            System.out.println("File " + args[0] + " does not exist.");
        }
        System.out.println("Parameters: <configuration file path>");
    }
    
    TestSuite suite; 
    public Eval(TestSuiteObserver observer, String[] args){
        debug("args.length = " + args.length);
        for(int i =0;i<args.length;i++){
            debug(args[i]);
        }
        suite = new TestSuite();
        if(args.length>=1 && new File(args[0]).exists()){
            suite.put("_CONFIGPATH",args[0]);            
        }else{
            suite.log("ERR", "No configuration found");
            err("No configuration found");
        }
        suite.setUp();
        suite.addObserver(observer);
        
    }

    public int getTestCount(){
        debug("Test count: " + suite.getTestCount());
        return suite.getTestCount();
    }
    public void run(){
        suite.run();
    }

    public void stop() {
        if(suite!=null){
            suite.stop();
        }
    }
    
}
